﻿using Framework.Resource;

namespace Framework.Procedure
{

    public class ProcedureResourceInit : ProcedureBase
    {
        private bool initFinish;
        public override void Enter(IProcedureOwner procedureOwner)
        {
            base.Enter(procedureOwner);
            initFinish = false;
            GameEntry.GetComponent<ResourceManager>().InitResource((result) =>
            {
                if (result)
                {
                    initFinish = true;
                }
                else
                {
                    Log.Info("resouce init 失败");
                }
            });
        }

        public override void Update(IProcedureOwner procedureOwner, float elapseSeconds, float realElapseSeconds)
        {
            base.Update(procedureOwner, elapseSeconds, realElapseSeconds);
            if (initFinish)
            {
                procedureOwner.ChangeState<ProcedureUpdateResourceVersion>();
            }
        }
    }

}